<?php

class MessageHelper Extends AppHelper {
	
	function get_reply_id($conversation = null) {
		if ($conversation == null) {
			return false;
		} else {
			if (count($conversation) > 1) {
				$prev_id = null;
				foreach($conversation as $message) {
					if (isset($id))
						$prev_id = $id;
					$id = $message['Message']['id'];
					if ($message['User']['id'] == $_SESSION['Auth']['User']['id'])
						$id = $prev_id;
				}
				return $id;
			} else {
				$id = $conversation[0]['Message']['id'];
				return $id;
			}
		}
	}
}

?>
